package controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import service.ProductManager;
import vo.Base;
import vo.Product;

@Controller
public class PmController {
	@Autowired
	private ProductManager pm;
	@ResponseBody
	@RequestMapping(value="/addBase",method=RequestMethod.POST)
	public String addBase(Base base){
		return pm.addBase(base);
	}
	
	@ResponseBody
	@RequestMapping(value="/findAllBases",method=RequestMethod.GET)
	public List<Base> findAllBases(){
		return pm.findAllBases();
	}
	
	@ResponseBody
	@RequestMapping(value="/findAllProducts",method=RequestMethod.GET)
	public List<Product> findAllProducts(){
		return pm.findAllProducts();
	}
	
	@ResponseBody
	@RequestMapping(value="/findProductsByBaseId",method=RequestMethod.GET)
	public List<Product> findProductsByBaseId(String id){
		return pm.findProductsByBaseId(id);
	}
	
	@ResponseBody
	@RequestMapping(value="/deleteBase",method=RequestMethod.GET)
	public int deleteBase(String id){
		return pm.deleteBase(id);
	}
}
